/**
 * @author MIAO
 * Created on 2011-10-10
 * For more information, please visit:ismiao.com
 */
package com.ismiao.designPattern.Observer.example2;

import java.util.Observable;
import java.util.Observer;

public class Display extends Observable implements Observer {

	private String status = "未开";

	public void setStatus(String status) {
		this.status = status;
	}

	public void displayTemperature(int temperature) {
		if (temperature > 95) {
			setStatus("沸腾");
			setChanged();
			notifyObservers();
		}
		System.out.println("状态：" + status + " 现在温度：" + temperature);
	}

	@Override
	public void update(Observable o, Object arg) {
		displayTemperature(((Heater) o).getTemperature());
	}

}
